//
//  ConfigInfo.m
//  DevSpoof
//
//  Created by huang on 2018/11/7.
//  Copyright © 2018年 wdys. All rights reserved.
//

#import "ConfigInfo.h"
#import "macserial.c"
#import "CommandLine.h"
#import "CloverConfigManager.h"

@implementation ConfigInfo
+ (instancetype)generateNew{
    ConfigInfo *config = [ConfigInfo new];
    config.smuuid = [CommandLine command:@"/usr/bin/uuidgen" argvs:nil].read;
    NSString *serialNum = nil;
    NSString *mbl = nil;
    SERIALINFO tmp = {
        .modelIndex  = -1,
        .decodedYear = -1,
        .decodedWeek = -1,
        .decodedCopy = -1,
        .decodedLine = -1,
    };
    tmp.modelIndex = get_current_model();
    if (get_serial(&tmp)) {
        char mlb[MLB_MAX_SIZE];
        get_mlb(&tmp, mlb, MLB_MAX_SIZE);
        serialNum = [ NSString stringWithFormat:@"%3s%s%s%s%s",tmp.country, tmp.year, tmp.week, tmp.line, tmp.model];
        mbl = [NSString stringWithUTF8String:mlb];
    }
    config.serialNumber = serialNum;
    config.mbl = mbl;
    return config;
}
@end
